#ifndef CALGORITHM_H
#define CALGORITHM_H

#include <QObject>
#include <QPoint>
#include <QStack>
#include <QThread>
#include <QQueue>

class CAlgorithm : public QObject
{
    Q_OBJECT

public:
    // 移动时 当前矩阵的状态
    enum eMatrixState
    {
        // 空闲点
        eMatrixStateNone,

        // 障碍物
        eMatrixStateObstacle,

        // 下一步的方向
        // 南，东，北，西
        eMatrixStateNextSouth,
        eMatrixStateNextEast,
        eMatrixStateNextNorth,
        eMatrixStateNextWest,
    };

public:
    explicit CAlgorithm(QObject *parent = 0);

    bool GetPathDFS(QPoint sourPoint, QPoint destPoint,
                 int **&matrix, int width, int height,
                 QStack < QPoint > &movePath);

    bool GetPathBFS(QPoint sourPoint, QPoint destPoint,
                 int **&matrix, int width, int height,
                 QStack < QPoint > &movePath);
signals:

public slots:

private:
    void MarkPoint(int ** &matrix, int width, int height, QPoint point, int flag);

    int MazeCellState(int ** &matrix, int width, int height, QPoint point);

    QPoint nextPos(QPoint pos, int di);

};

struct BFSPathCell
{
    // 当前路径
    QPoint curPoint;

    // 前驱路径
    QPoint prePoint;
};

#endif // CALGORITHM_H
